<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<html:html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>客户信息管理</title>
	<META http-equiv=Pragma content=no-cache>
	<META http-equiv=Cache-Control content=no-cache>
	<META http-equiv=Expires content=0>
	<link rel="stylesheet"
		href="<%=request.getContextPath()%>/resource/css/style.css"
		type="text/css">
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/AdyhUtil.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/calendar/DCDA_C03.js"></script>
	<link rel="stylesheet" type="text/css"
		href="<%=request.getContextPath()%>/style/ext/resources/css/ext-all.css" />
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/load.js"></script>
	<script type="text/javascript">
	function getMessage() {
	var errorMsg = document.forms[0].errorFlag.value;
	if ("" != errorMsg) {
		//**操作成功！*/
		if (errorMsg == 0) {
			alert("<bean:message key="common.alert1"/>");
		}
		//**操作失败！*/
		if (errorMsg == 1) {
			alert("<bean:message key="common.alert2"/>");
		}
		//**查询无结果！*/
		if (errorMsg == 2) {
			alert("<bean:message key="common.alert3"/>");
		}
		//**系统异常，请联系管理员！*/
		if (errorMsg == 3) {
			alert("<bean:message key="common.alert4"/>");
		}
		document.forms[0].errorFlag.value = "";
	}
}
	/** 保存数据，返回booelan */
	function JudgmentSample(h,manufacturing_order,group){
 			var stock_reason;
 			var count;
			if(h>0){
			count=h-1;
				stock_reason = document.forms[0].stock_reason[count].value;	
			}else{
				stock_reason = document.forms[0].stock_reason.value;	
			}
  		 Ext.Ajax.request({
		 	 url : 'F010103.do' , 
			 params : {operationType:'update',stock_reason:stock_reason,manufacturing_order:manufacturing_order,group:group},
			 method: 'POST',
			 success: function ( result, request) {
				      var obj= Ext.decode(result.responseText) ;
					  var flag = obj.data.value1;
					  if(flag=="0"){
							if(h>0){				
								document.forms[0].stock_reason[count].disabled=true;
							}else{
								document.forms[0].stock_reason.disabled=true;
							}
						alert("保存成功!");
					  }else{
						alert("保存失败!");
					  }	
			},
			failure: function ( result, request) { 
				window.parent.alert("无法连接服务器和数据库，请和系统管理员联系！");
			} 
				});
			}
			function operation(type) {
				sAlert();
	document.forms[0].operationType.value = type;
	document.forms[0].submit();
}
	</script>
	<%
	List KUYY = (List) request.getAttribute("KUYY");
	%>

</head>
<body onLoad="getMessage();">
	<html:form method="post" action="/pages/F01/F010103.do"
		enctype="multipart/form-data">
		<html:hidden property="operationType" />
		<html:hidden property="errorFlag" />
		<html:hidden property="id" />
		<html:hidden property="id1" />
		<html:hidden property="language" />
		<!--Begin：表单折叠区块1-->
		<div id="divDlock_2" class="DivBlock">
			<div class="DivHead">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td nowrap class="line_wrap" width="37" height="17">
							<img
								src="<%=request.getContextPath()%>/resource/image/block_unwrap.gif"
								style="CURSOR: hand;" alt="展开/折叠"
								onClick="JavaScript:WrapBlock('divDlock_2');">
						</td>
						<td nowrap class="line_wrap" width="100%" height="17">
							<span class="SpanTitle"><span class="SpanTitle"><bean:message key="F01.F010103" /></span></span>
						</td>
					</tr>
				</table>
			</div>
			<div class="DivTail" style="display:block">
				<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
					<TR>
						<TD NOWRAP>
							<!--订单号码	-->
							<bean:message key="F010103.cotract_number" />
						</TD>
						<TD NOWRAP>
							<html:text property="cotract_number" styleClass="MyText" />
						</TD>
						<TD NOWRAP>
							<!--入库时间	-->
							<bean:message key="F010103.stock_date" />
						</TD>
						<TD NOWRAP>
							<html:text property="stock_date_begin" styleClass="MyText130"
								onclick="return CalendarClick(this)" />
							<bean:message key="F01.common.to" />
							<html:text property="stock_date_end" styleClass="MyText130"
								onclick="return CalendarClick(this)" />
						</TD>
					</TR>
					<TR>
						<TD NOWRAP>
							<!--工 作 号		-->
							<bean:message key="F010103.manufacturing_order" />
						</TD>
						<TD NOWRAP>
							<html:text property="manufacturing_order" styleClass="MyText" />
						</TD>
					</TR>
				</TABLE>
			</div>
		</div>
		<!--End：表单折叠区块1-->
		<!--Begin：表单按钮及提示区-->
		<div class="DivBlock">
			<div class="DivButton" style="text-align:right ">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td align="right">
							<input type="button" name="Submit1" class="MyButton"
								value="<bean:message key="common.query"/>"
								onClick="javascript:operation('queryList');">
							<input type="button" name="Submit2" class="MyButton"
								value="<bean:message key="common.back"/>"
								onClick="window.location='../../frame/blank.html'">
						</td>
					</tr>
				</table>
			</div>
		</div>
		<!--End：表单按钮及提示区-->
		<!--Begin：查询列表-->
		<logic:present name="F010103ActionForm" property="list">
			<div>
				<table id="tbList" width="100%" cellpadding="1" cellspacing="1"
					border="0" rules="none" class="ListBackground">
					<tr align="center" class="ListTitle">
						<!--<td nowrap>
							订单号码
							<bean:message key="F010103.cotract_number" />
						</td>-->
						<td align="center" nowrap>
							<!--工 作 号-->
							<bean:message key="F010103.manufacturing_order" />
						</td>
						<td nowrap>
							<!--客户名称-->
							<bean:message key="F010103.customer_code" />
						</td>
						<td nowrap>
							<!--组-->
							<bean:message key="F010103.group" />
						</td>
						<td nowrap>
							<!--数量-->
							<bean:message key="F010103.qty" />
						</td>
						<td nowrap>
							<!--入库时间-->
							<bean:message key="F010103.stock_date" />
						</td>
						<td nowrap>
							<!--销售单价-->
							<bean:message key="F010103.unit_price" />
						</td>
						<td nowrap>
							<!--销售总价-->
							<bean:message key="F010103.selltotalprice" />
						</td>
						<td nowrap>
							<!--成本单价-->
							<bean:message key="F010103.material_cost" />
						</td>
						<td nowrap>
							<!--成本总价-->
							<bean:message key="F010103.costtotalprice" />
						</td>
						<td nowrap>
							<!--库存原因-->
							<bean:message key="F010103.stock_reason" />
						</td>
						<td nowrap>
							<!--操作-->
							<bean:message key="common.operate" />
						</td>
					</tr>
					<%
					int i = 1;
					%>
					<logic:iterate id="rowp" name="F010103ActionForm" property="list">
						<tr class="ListRow1">
						<!-- 	<td nowrap align="center">
								<bean:write name="rowp" property="cotract_number" />
							</td> -->
							<td nowrap align="center">
								<bean:write name="rowp" property="manufacturing_order" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="customer_code" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="group" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="qty" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="stock_date" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="unit_price" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="selltotalprice" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="material_cost" />
							</td>
							<td nowrap align="center">
								<bean:write name="rowp" property="costtotalprice" />
							</td>
							<td nowrap align="center">
								<select name="stock_reason" class="MySelect">
									<%
											List list = (List) request.getAttribute("list");
											String a = ((Map) list.get(i - 1)).get("stock_reason")
											.toString();
											for (int m = 0; m < KUYY.size(); m++) {
												String code = ((Map) KUYY.get(m)).get("CODE").toString();
												String name = ((Map) KUYY.get(m)).get("NAME").toString();
												if (a.equals(code)) {
									%>
									<option value="<%=code%>" selected="selected">
										<%=name%>
									</option>
									<%=code%>
									<%
									} else {
									%>
									<option value="<%=code%>">
										<%=name%>
									</option>
									<%
											}
											}
									%>
								</select>
							</td>
							<td nowrap align="center">
								<a
									href="javascript:JudgmentSample('<%=i++%>','<bean:write name="rowp" property="manufacturing_order" />','<bean:write name="rowp" property="group" />')"><bean:message
										key="common.save" /> </a>
							</td>
						</tr>
					</logic:iterate>
				</table>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="fieldset2">
							<bean:define id="actionFormName" value="F010103ActionForm" />
							<%@ include file="../../style/pagejsp/pageable.jsp"%>
						</td>
					</tr>
				</table>
			</div>
		</logic:present>
		<!--End：查询列表-->
	</html:form>
</body>
</html:html>
<script language="javascript" type="text/javascript">
InitForm();
FocusTableRow("tbList",1);
</script>
